<?php

namespace App\Http\Requests\Logic\Attendance;

use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;

/**
 * 考勤日报
 *
 * Date: 2018/6/19
 * @author George
 * @package App\Http\Requests\Logic\Attendance
 */
class ReportOfDay extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        $user = Auth::user();
        // 判断是否有查看考勤报表的权限
        if ($user->hasPermission('attendance_report')) {
        	return true;
		}
		return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
        	'project_id' => 'required',
			'date' => 'nullable',
        ];
    }

	/**
	 * Define validation error messages of response
	 *
	 * Date: 2018/6/19
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'project_id.required' => '请选择要查询的项目',
		];
    }
}
